<?
    require_once("mvc/action/ActionForm.php");
    require_once("mvc/action/ActionMessage.php");
    require_once("mvc/action/ActionMessages.php");

    require_once("cms/core/om/CategoryI18n.php");


    class BaseAbstractForm extends ActionForm {

        protected $categoryI18n;
        protected $formImage;
        protected $deleteImage;

        public function __construct() {
            $this->categoryI18n = new CategoryI18n();
            $this->formImage = null;
            $this->deleteImage = false;
        }

        public function getCategoryI18n() {
            return $this->categoryI18n;
        }

        public function setCategoryI18n(CategoryI18n $categoryI18n) {
            $this->categoryI18n = $categoryI18n;
        }

        public function getFormImage() {
            return $this->formImage;
        }

        public function setFormImage($formImage) {
            $this->formImage = $formImage;
        }

        public function getDeleteImage() {
            return $this->deleteImage;
        }

        public function setDeleteImage($deleteImage) {
            $this->deleteImage = $deleteImage;
        }

        public function validate() {

            $errors = new ActionMessages();

            if(is_null($this->getCategoryI18n()->getName()) || strlen($this->getCategoryI18n()->getName()) == 0)
                $errors->add("categoryI18n->name",
                    new ActionMessage("errors.required", true, new ActionMessage("prompt.name", true)));


            if(!is_null($this->getCategoryI18n()->getName()) && strlen($this->getCategoryI18n()->getName()) > 0 && strlen($this->getCategoryI18n()->getName()) > 255)
                $errors->add("categoryI18n->name",
                    new ActionMessage("errors.maxlength", true, array(
                        new ActionMessage("prompt.name", true),
                        new ActionMessage("255", false))));


            global $ALLOWABLE_IMAGES;
            if(!is_null($this->getFormImage()) && isset($this->formImage["size"]) && $this->formImage["size"] > 0 && !array_key_exists($this->formImage["type"], $ALLOWABLE_IMAGES))
                $errors->add("formImage",
                    new ActionMessage("errors.image", true, new ActionMessage("prompt.image", true)));

            return $errors;
        }

    }
?>